package com.zhiyou100.service;

import com.zhiyou100.entity.Student;
import com.zhiyou100.mapper.StudentMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author yang
 * @className StudentServiceImpl
 * @packageName com.zhiyou100.service
 * @Description TODO 学生实现类
 * @date 2020-08-25 19:52
 */
@Repository
public class StudentServiceImpl implements StudentService {
    private StudentMapper studentMapper;


    @Autowired
    public void setStudentMapper(StudentMapper studentMapper) {
        this.studentMapper = studentMapper;
    }

    @Override
    public List<Student> getStudentList() {
        return studentMapper.selectAll();
    }

    @Override
    public int addStudent(Student student) {
        return studentMapper.insert(student);
    }

    @Override
    public int deleteStudent(Integer sid) {
        return studentMapper.deleteByPrimaryKey(sid);
    }

    @Override
    public int updateStudent(Student student) {
        return studentMapper.updateByPrimaryKeySelective(student);
    }

    @Override
    public Student getStudentById(Integer sid) {
        return studentMapper.selectByPrimaryKey(sid);
    }
}
